home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // Yahoo Movies (Quick Picture Grab)
-
- (**************************************************
- * Movie importation script for: *
- * Yahoo Movies - http://movies.yahoo.com *
- * *
- * (c) 2003 NoFiX *
- * *
- * For use with Ant Movie Catalog 3.4.2 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
-
- program YahooPictureGrab;
- const
- YMGrabPlot = FALSE;
- var
- MovieName: string;
-
- procedure AnalyzePage(Address: string);
- var
- debugPage: TStringList;
- strPage, MovieAddr, MovieTitle, MoviePlot, MovieID: string;
- BeginPos, EndPos: Integer;
- begin
- // debugPage:= TStringList.Create;
- // debugPage.Text := GetPage(Address);
- // debugPage.SaveToFile('C:\Yahoo1.txt');
- strPage:= GetPage(Address);
- BeginPos:= Pos('Titles Found</b>', strPage);
- Delete(strPage, 1, BeginPos);
- if(BeginPos > 0) then
- begin
- PickTreeClear;
- PickTreeAdd('Results for ' + MovieName + ':', '');
- BeginPos:= Pos('<a HRef="', strPage);
- while BeginPos > 0 do
- begin
- // Movie Address
- EndPos:= Pos('">', Copy(strPage, BeginPos, Length(strPage) - BeginPos)) + BeginPos - 1;
- MovieAddr:= Copy(strPage, BeginPos + 9, EndPos - BeginPos - 9);
- // Movie Title
- BeginPos:= EndPos + 2;
- EndPos:= Pos('</a>', strPage);
- MovieTitle:= Copy(strPage, BeginPos, EndPos - BeginPos);
- // Add to listbox
- PickTreeAdd(MovieTitle, MovieAddr);
- // Restart the process
- Delete(strPage, 1, EndPos);
- BeginPos:= Pos('<a HRef="', strPage);
- end;
- if(PickTreeExec(Address)) then
- begin
- strPage:= GetPage(Address);
- BeginPos:= FindBefore('<img src="', strPage, Pos('"Movie Image"', strPage));
- if(BeginPos > 0) then
- begin
- Delete(strPage, 1, BeginPos + 9);
- EndPos:= Pos('"', strPage);
- Address:= Copy(strPage, 1, EndPos - 1);
- GetPicture(Address, FALSE);
- end
- else
- ShowMessage('No cover-art was found for :' + MovieName);
- // Check if we need plot
- if(GetField(fieldDescription) = '') or (YMGrabPlot = TRUE) then
- begin
- BeginPos:= Pos('<font face=arial size=-1><b>' + #13, strPage) + 35;
- ShowMessage(IntToStr(BeginPos));
- Delete(strPage, 1, BeginPos);
- EndPos:= Pos('<p>', strPage);
- MoviePlot:= Copy(strPage, 1, EndPos - 3);
- HTMLDecode(MoviePlot);
- SetField(fieldDescription, MoviePlot);
- end;
- end;
- end;
- end;
-
- Function FindBefore(wordToFind: string; text: string; sPos: Integer):Integer;
- var
- iPos, iFound: Integer;
- begin
- Text:= Copy(Text, 1, sPos);
-
- iPos:= Pos(wordToFind, Text);
- iFound:= iPos;
- while iPos > 0 do
- begin
- if(iPos > 0) then
- Delete(Text, 1, iPos);
-
- iPos:= Pos(wordToFind, Text);
- iFound:= iFound + iPos;
- end;
- result:= iFound;
- end;
-
- begin
- if CheckVersion(3,4,2) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- begin
- AnalyzePage('http://search.movies.yahoo.com/search/movies/title?p=%5B' + UrlEncode(MovieName) + '%5D+type%3Afeature&intl=us&search=title&s=wt,-$s');
- end;
- end else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.2)');
- end.
-